package com.yxq.mdt.app.modules.auction.adapter;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.auction.bean.MyTeamFansBean;

import java.util.List;

public class AuctionMyTeamAdapter extends BaseQuickAdapter<MyTeamFansBean.ListBean, BaseViewHolder> {
    public AuctionMyTeamAdapter(int layoutResId, @Nullable List<MyTeamFansBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyTeamFansBean.ListBean item) {
        GlideHelper.setLoadRoundImage(mContext, item.getAvatarUrl(), 0, helper.getView(R.id.my_team_nike_img));
        helper.setText(R.id.my_team_nike_name, item.getNickname());
        helper.setText(R.id.my_team_time_tv, TimeUtils.date2String(TimeUtils.string2Date(item.getCreateTime()), "yyyy-MM-dd"));
        helper.setText(R.id.my_team_level, getLevelDesc(item.getCurrentRole()));
        helper.setTextColor(R.id.my_team_level, item.getCurrentRole() == 0 ? mContext.getResources().getColor(R.color.color_font_black) : mContext.getResources().getColor(R.color.color_font_red));
        helper.setGone(R.id.fans_list_label, (helper.getLayoutPosition() == 0));

        helper.setGone(R.id.my_team_mobile, (item.getCurrentRole() != 0));
        if (item.getCurrentRole() != 0) {
            helper.setText(R.id.my_team_mobile, item.getMobile() + "");
        }
    }

    private String getLevelDesc(int level) {
        switch (level) {
            case 0:
                return "普通用户";
            case 1:
                return "团长";
            case 2:
                return "区县代理";
            case 3:
                return "预备团长";
        }
        return "";
    }
//    private String formatNickName(String nick) {
//        if (!TextUtils.isEmpty(nick)) {
//            //不为空
//            if (StringUtils.isMobileExact(nick)) {
//                //是手机号码
//                String lastNumber = (nick.substring(nick.length() - 4, nick.length()));
//                String firstNumber = nick.substring(0, 3);
//                return (firstNumber + "***" + lastNumber);
//            } else {
//                //昵称大于7个字符
//                if (nick.length() > 7) {
//                    return nick.substring(0, 7) + "***";
//                } else {
//                    return nick;
//                }
//
//            }
//        } else {
//            return "--";
//        }
//    }
}
